package main

import (
	"fmt"
	"yundian/internel/app/dao"
	"yundian/internel/app/logic"
	"yundian/internel/app/models/orders"
	"yundian/internel/pkg/alipay"
	. "yundian/internel/pkg/dbs"
	. "yundian/internel/pkg/dingo"
	"yundian/internel/pkg/dingo/system"
)

func main() {
	system.New("./configs/alipay.yaml").
		Ready(
			NewZapComponent(),   // logger 日志管理
			NewMysqlComponent(), // mysql 连接
			NewRedisComponent(), // redis 连接
			NewTransComponent(), // validator 翻译器
		)

	var bodyMap = alipay.BodyMap{}
	//map[app_id:2021002163609520 auth_app_id:2021002163609520 buyer_id:2088022768301641 buyer_logon_id:137****6475 buyer_pay_amount:0.01 charset:utf-8 fund_bill_list:[{"amount":"0.01","fundChannel":"PCREDIT"}] gmt_create:2023-04-08 17:15:08 gmt_payment:2023-04-08 17:15:30 invoice_amount:0.01 notify_id:2023040801222171531001641401073977 notify_time:2023-04-08 17:40:36 notify_type:trade_status_sync out_trade_no:ZM20230408171507737304 passback_params:attach=8dd1dc6b93165839df897b2ec28cc417&device_info=220516ZM00004 point_amount:0.00 receipt_amount:0.01 seller_email:cnman17607709666@163.com seller_id:2088041105272721 sign:S1iZCc8pYuIcmrsZRgxVX8F/e9EJNgS3y74g5W6pUVqGDYyIjiXPGw/Irl6t+93Pq73o4XxcT+5vay8i2BiQTf42xsdfbvqYQH3JchuGka0KeixCdW1C3Hj2JC34malUkRJhj1Ihg3jHxVFdYgkdjZiL5VuFzyXRCX+ubELc91Ie+hlMF21Fy13JmHhJhRGrYcJVktBTDxTgj2UBVuzxkz6y0gnqj6AZ9F6P+muE/mCfXjWLWAGLy+scdpYjaZlQWN6z7bEDVqChE4XwQmynTAKstwlF+bFJPMs7IpJpAMMOg20DvPrlTM8V9V+kDDjaSHTCiBEioOvaSpiYf8HD6w== sign_type:RSA2 subject:中曼密码线充 total_amount:0.01 trade_no:2023040822001401641408769374 trade_status:TRADE_SUCCESS version:1.0]
	bodyMap.Set("trade_status", "TRADE_SUCCESS")
	bodyMap.Set("app_id", "2021002163609520")
	bodyMap.Set("buyer_id", "2088022768301641")
	bodyMap.Set("out_trade_no", "ZM20230408171507737304")
	bodyMap.Set("trade_no", "2023040822001401641408769374")
	bodyMap.Set("passback_params", "attach=8dd1dc6b93165839df897b2ec28cc417&device_info=220516ZM00004")
	bodyMap.Set("total_amount", "0.01")
	bodyMap.Set("buyer_pay_amount", "0.01")
	bodyMap.Set("notify_time", "2023-04-08 17:40:36")
	//alipayh.DepositPayResultNotify(bodyMap)

	orderInfo := dao.NewOrderDao().WxGetOrderInfoByTradeNo(bodyMap.Get("out_trade_no")).Unwrap().(*orders.OrderModel)
	orderLogic := logic.NewAliPayOrderLogic()

	respData, err := orderLogic.AliPayOrderMessage(orderInfo)
	fmt.Println("AliPayOrderMessage", respData, err)

	{
		//time.Sleep(60 * time.Second)
		respData, err := orderLogic.AliPaySubscribeMessage(orderInfo)
		fmt.Println("AliPaySubscribeMessage", respData, err)
	}
}
